package com.jiedeng.controller.index;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.jiedeng.controller.Rst;
import com.jiedeng.model.Person;
import com.jiedeng.util.SessionUtil;
import com.jiedeng.util.httpclient.HttpClientHelper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class CommonComponent {
    @Value("${config.http.client.url}")
    public String url;
    public Rst checkModuleRule(String byname) {
        String ret = null;
        try {
            Person person = (Person) SessionUtil.getUserSession();
            String getUrl = url + "/jurisdictionit/checkModuleRule?byname=" + byname + "&postId=" + person.getPostId() + "&corpId=" + person.getCorpId();
            ret = HttpClientHelper.doGet(getUrl);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Rst rst = JSON.parseObject(ret.trim(), new TypeReference<Rst>() {
        });
        return rst;
    }
}
